package cn.takovh.zpl.bean;

import org.dom4j.Element;

import java.util.Iterator;
import java.util.List;

public class Body implements ElementBean {
    private Seq seq;

    public Body(Seq seq) {
        this.seq = seq;
    }

    public Body() {
    }

    public Body(List<Media> mediaList) {
        this.seq = new Seq(mediaList);
    }

    public Seq getSeq() {
        return seq;
    }

    public void setSeq(Seq seq) {
        this.seq = seq;
    }

    @Override
    public void getElement(Element root) {
        Element c1 = root.addElement("seq");
        seq.getElement(c1);
    }

    @Override
    public void parseElement(Element root) {
        this.seq = new Seq();

        for (Iterator<Element> it = root.elementIterator(); it.hasNext(); ) {
            Element element = it.next();
            String name = element.getName();
            switch (name) {
                case "seq":
                    this.seq.parseElement(element);
                    break;
                default:
                    throw new IllegalArgumentException(name);
            }
        }
    }
}
